import 'package:XinXiZiXun/common/states/theme_color_provider.dart';
import 'package:XinXiZiXun/common/utils/screen.dart';
import 'package:XinXiZiXun/common/values/colors.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

class SystemThemeColorPage extends StatefulWidget {
  @override
  _SystemThemeColorPageState createState() => _SystemThemeColorPageState();
}

class _SystemThemeColorPageState extends State<SystemThemeColorPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          '颜色主题',
          style: TextStyle(
              color: AppColors.primaryBlackColor,
              fontSize: duSetScaleFontSize(32),
              fontFamily: 'Avenir',
              fontWeight: FontWeight.w600),
        ),
      ),
      body: ExpansionTile(
        leading: Icon(Icons.color_lens),
        title: Text(
          '颜色主题',
          style: TextStyle(
              fontSize: duSetScaleFontSize(24),
              color: AppColors.primaryDarkGrayColor),
        ),
        children: [
          Padding(
            padding: const EdgeInsets.all(10.0),
            child: Wrap(
              spacing: 5,
              runSpacing: 5,
              children: [
                ...Colors.primaries
                    .map((color) => Material(
                          color: color,
                          child: InkWell(
                            child: Container(
                              width: duSetWidth(40),
                              height: duSetWidth(40),
                            ),
                            onTap: () {
                              //provider获取颜色值
                              context
                                  .read<ThemeColorProvider>()
                                  .changeThemeColor(color: color);
                            },
                          ),
                        ))
                    .toList()
              ],
            ),
          )
        ],
      ),
    );
  }
}
